import { CSSColor } from '../graph/base'

export class LineGradient {
  private _x0: number = 0
  private _y0: number = 0
  private _x1: number = 100
  private _y1: number = 0
  private colors: []
  private canvas: HTMLCanvasElement = document.createElement('canvas')
  private ctx: CanvasRenderingContext2D = this.canvas.getContext('2d')
  private gradient: CanvasGradient
  constructor(x0: number, y0: number, x1: number, y1: number) {
    this._x0 = x0
    this._y0 = y0
    this._x1 = x1
    this._y1 = y1
    this.gradient = this.ctx.createLinearGradient(this._x0, this._y0, this._x1, this._y1)
  }
  public add(offset: number, color: CSSColor) {
    this.gradient.addColorStop(offset, color)
  }
  public get(): CanvasGradient {
    return this.gradient
  }
}
